package com.ruoyi.hqfinance.service.impl;

import com.github.pagehelper.PageHelper;
import com.ruoyi.hqfinance.domain.HqFcSheet;
import com.ruoyi.hqfinance.domain.HqKuaiBaoSheet;
import com.ruoyi.hqfinance.domain.vo.HqPlatformBillSheetVo;
import com.ruoyi.hqfinance.mapper.HqFcSheetMapper;
import com.ruoyi.hqfinance.mapper.HqKuaiBaoSheetMapper;
import com.ruoyi.hqfinance.service.HqPlatformBillSheetService;
import com.ruoyi.logistic.domain.PageDate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HqPlatformBillSheetServiceImpl implements HqPlatformBillSheetService {
    @Autowired
    private HqKuaiBaoSheetMapper hqKuaiBaoSheetMapper;
    @Autowired
    private HqFcSheetMapper hqFcSheetMapper;
    @Override
    public List<HqKuaiBaoSheet> collectKB(HqPlatformBillSheetVo hqPlatformBillSheetVo) {
        PageHelper.startPage(hqPlatformBillSheetVo.getPageDate());
        List<HqKuaiBaoSheet> kuaiBaoSheets = hqKuaiBaoSheetMapper.collect(hqPlatformBillSheetVo);
        assert kuaiBaoSheets != null;
        for (HqKuaiBaoSheet hqKuaiBaoSheet : kuaiBaoSheets){
            if (hqPlatformBillSheetVo.getCollectType() == 1){
                hqKuaiBaoSheet.setDate(hqPlatformBillSheetVo.getStartTime() + "至" + hqPlatformBillSheetVo.getEndTime());
            }
        }
        return kuaiBaoSheets;
    }

    @Override
    public List<HqFcSheet> collectFC(HqPlatformBillSheetVo hqPlatformBillSheetVo) {
        PageHelper.startPage(hqPlatformBillSheetVo.getPageDate());
        List<HqFcSheet> hqFcSheets = hqFcSheetMapper.collectFC(hqPlatformBillSheetVo);
        assert hqFcSheets != null;
        for (HqFcSheet hqFcSheet : hqFcSheets){
            if (hqPlatformBillSheetVo.getCollectType() == 1){
                hqFcSheet.setDate(hqPlatformBillSheetVo.getStartTime() + "至" + hqPlatformBillSheetVo.getEndTime());
            }
        }
        return hqFcSheets;
    }
}
